﻿@using TestUp.Models.AdminModels
@model ViewGroupsModel
@{
    ViewBag.Title = "View Groups";
    Layout = "~/Views/Admin/_AdminLayout.cshtml";
}

<h2>ManageGroups</h2>

@(Html.Kendo().Grid(Model.Groups)
    .Name("groupsGrid")
    .Columns(cols =>
        {
            cols.Bound("GroupId").Hidden(true);
            cols.Bound("GroupName").ClientTemplate("<a href='" + Url.Action("ViewUsers", "Admin", new { id = "#=GroupId#" }) + "'>#=GroupName#</a>");
            cols.Command(cmd => cmd.Edit());
            cols.Command(cmd => cmd.Destroy());
        })
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
    .ToolBar(cmd => cmd.Create())
    .DataSource(dataSource => dataSource
        .Server()
        .Model(model =>
            {
                model.Id(item => item.GroupId);
                model.Field(field => field.GroupId).Editable(false);
            })
        .Create(create => create.Action("CreateGroup", "Admin"))
        .Update(update => update.Action("EditGroup", "Admin"))
        .Destroy(destroy => destroy.Action("DeleteGroup", "Admin"))
        )
      )
